﻿using System;
using System.Collections.Generic;
using System.Text;
using OneMG.Phoenix.Service.Contracts;
using OneMG.Phoenix.Service.Model;
using OneMG.Phoenix.IBatisRepository;
using OneMG.Phoenix.Respository;
using System.Data;
using OneMG.Phoenix.Entity;

namespace OneMG.Phoenix.Service
{
    public class AdminUserLogInfoService : IAdminUserLogInfoService
    {
		 IAdminUserLogInfo adminUserLogInfo = new AdminUserLogInfoRepository();
		 
        public System.Int64 AddAdminUserLogInfo(AdminUserLogInfoModel model)
        {
			EAdminUserLogInfo entity = ConvertModelToEntity(model);
			
            return adminUserLogInfo.AddAdminUserLogInfo(entity);
        }

		public void UpdateByLogID (AdminUserLogInfoModel model)
		{
			EAdminUserLogInfo entity = ConvertModelToEntity(model);

            adminUserLogInfo.UpdateByLogID(entity);

		}

		public void DeleteByLogID (System.Int64 logID)
		{
		
            adminUserLogInfo.DeleteByLogID(logID);

		}
		 
        public AdminUserLogInfoModel GetByLogID (System.Int64 logID)
        {
        
			EAdminUserLogInfo entity = adminUserLogInfo.GetByLogID(logID);
			
            AdminUserLogInfoModel model = ConvertEntityToModel(entity);


            return model;
        }
        
		public AdminUserLogInfoModel ConvertEntityToModel(EAdminUserLogInfo entity)
		{
			if (entity == null)
            {
                return null;
            }
			AdminUserLogInfoModel model = new AdminUserLogInfoModel();
                        model.LogID = entity.LogID;
                        model.UserID = entity.UserID;
                        model.LogIP = entity.LogIP;
                        model.LogTime = entity.LogTime;
                        model.Description = entity.Description;
                        return model;
		}
		
		public EAdminUserLogInfo ConvertModelToEntity(AdminUserLogInfoModel model)
		{
			if (model == null)
            {
                return null;
            }
			EAdminUserLogInfo entity = new EAdminUserLogInfo();
                        entity.LogID = model.LogID;
                        entity.UserID = model.UserID;
                        entity.LogIP = model.LogIP;
                        entity.LogTime = model.LogTime;
                        entity.Description = model.Description;
                        return entity;
		}
    }
}